import { Table } from 'antd';
import React from 'react';

//定义字段
const columns = [

  {
    title: '分类名称',
    dataIndex: 'sortName',
    key: 'sortName',
    width: '70%',
  },
  {
    title: '序号',
    dataIndex: 'sortCode',
    width: '10%',
    key: 'sortCode',
  },
  {
    title: '是否显示',
    dataIndex: 'isShow',
    width: '10%',
    key: 'isShow',
    render:function(text){
        if(text === '0'){
          return <span style={{backgroundColor:'#dc3545'}}>不显示</span>
        }else{
          return <span style={{backgroundColor:'#3ed68f'}}>显示</span>
        }
    }
  },
];

const rowSelection = {
  onChange: (selectedRowKeys, selectedRows) => {
    console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
  },
  onSelect: (record, selected, selectedRows) => {
    console.log(record, selected, selectedRows);
  },
  onSelectAll: (selected, selectedRows, changeRows) => {
    console.log(selected, selectedRows, changeRows);
  },
};
const ProductTypeTableTree = (props) => {
  return (
      <Table
        columns={columns}
        rowSelection={{
          ...rowSelection,
        }}
        dataSource={props.dataSource}
      />
  );
};
export default ProductTypeTableTree;